const Koa = require('koa');
// const fs = require('fs.promised');
const Query = require('../function/query');
const db = require('../mysql/link');

// const path = require('path');
// const serve = require('koa-static');
const app = new Koa();

// const main = serve(path.join(__dirname));
const main = async function(ctx, next) {
    ctx.response.type = 'html';
    // ctx.response.body = await fs.readFile('./server.html', 'utf8');
    ctx.response.body = await db.query('select * from user_info', [], (result, fields) => {
        console.log(ctx);
        // console.log(result);
        // console.log(JSON.stringify(result));
        return JSON.stringify(result);
    });

    // console.log(ctx);

};
// console.log(path.join(__dirname));
app.use(main);
app.listen(3000);